<?php
namespace Admin\Model;
use Think\Model\ViewModel;
class BlogViewModel extends ViewModel{
	public $viewFields = array(
		'Blog'=>array('id','title','click','time','type','cid','_type'=>'LEFT'),
		'Category'=>array('id'=>'c_id','name'=>'c_name', '_on'=>'Blog.cid=Category.id','_type'=>'LEFT'),
		'Attr'=>array('id'=>'a_id','name'=>'a_name','color', '_on'=>'Blog.type=Attr.id')
		);

	public function getBlogs($limit,$search,$del=0){
		$where = array('title'=>array('like',"%".$search."%"),'del'=>$del);
		$field = array('id','title','c_name','click','a_name','color','time');
		return $this->field($field)->where($where)->limit($limit)->order('type DESC,time DESC')->select();
	}

}